#
# @lc app=leetcode.cn id=367 lang=python3
#
# [367] 有效的完全平方数
#

# @lc code=start
class Solution:
    def isPerfectSquare(self, num: int) -> bool:
        if num == 0 or num == 1:
            return True
        
        min = 1
        max = num
        while min <= max:
            mid = (min + max)//2
            # 说明最小值已经是min了
            if mid * mid > num:
                max = mid - 1
            elif mid * mid < num:
                min = mid + 1
            else:
                return True 
            
        return False
# @lc code=end

